<template>
    <div class="wangji">
    <div class="dl">
    <div class="rtop">重置密码</div>
         <div class="in">
        邮箱
        <br />
        <br />
        <input ref='em' type="text"  id="mm" @change="yzyx"/>
      </div>
      <div class="login" @click="next">
            发送
      </div>
      <div class="zzz"><div>你已有账号?<span style="margin-left:1em" @click="denglu()">用户登录</span></div><div>建立新账号?<span style="margin-left:1em" @click="zhuce">用户注册</span></div></div>
    </div>
    </div>
</template>

<script>
import {ElMessage} from 'element-plus'
export default {
       name:'MmOne',
       data(){
        return{
            chongzhi:false
        }
       },
       methods:{
        denglu(){
            this.$store.commit('denglu')
        },
        zhuce(){
            this.$store.commit('zhuce')
        },
        next(){
        if(this.chongzhi==true){
                 this.$store.commit('mmtwo')
        }else{
             ElMessage({
        message: '请重新输入邮箱',
        type: 'warning',
       })
        }

          
        },
            //验证邮箱格式
       yzyx(e){
       let emailReg = /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/;
       let add=e.target.value
       if(!emailReg.test(add)){
        ElMessage({
        message: '邮箱格式错误，请重新输入邮箱',
        type: 'warning',
       })
       }else{
        this.chongzhi=true
       }
      
       },
       }
}
</script>

<style>

</style>